<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <div>a</div>
  <iframe id="frame" src="http://localhost:4000/c.html" frameborder="0" onload="load()"></iframe>
  <script>
    let first = true;

    function load() {
      if (first) {
        let frame = document.getElementById("frame");
        frame.src = "http://localhost:3000/b.html"
        first = false;
      } else {
        console.log(frame.contentWindow.name);
      }
    }
  </script>
</body>

</html>